package com.szqhyxj.youxiangju.biz.partnerHome.equipment.currentRecord;

import com.szqhyxj.youxiangju.biz.partnerHome.equipment.bean.Record;
import com.szqhyxj.youxiangju.sys.BaseResult;
import com.szqhyxj.youxiangju.sys.RetrofitFacade;

import java.util.List;

import io.reactivex.Observable;
import retrofit2.http.POST;

/**
 * XiaoPanYu
 * on 2018/11/22
 */
public class CurrentRecordModel{

    public static final  int RECORD_TYPE = 0;
    public static final  int ACTIVATE_TYPE = 1;
    public static final  int OUT_TYPE = 2;

    public interface CurrentRecordService {
        @POST("record/putRecord")
        Observable<BaseResult<List<Record>>> getRecordRecord();

        @POST("record/activateRecord")
        Observable<BaseResult<List<Record>>> getRecordActivateRecord();
        //record/activateRecord
        //record/outRecord
        @POST("record/outRecord")
        Observable<BaseResult<List<Record>>> getRecordOutRecord();
    }

    /**
     * 设备管理-入库记录
     * @return
     */
    public static Observable<BaseResult<List<Record>>> getRecord() {
        return RetrofitFacade.Companion.getRetrofit().create(CurrentRecordService.class).getRecordRecord();
    }

    /**
     * 设备管理-激活记录
     */
    public static Observable<BaseResult<List<Record>>> getRecordActivate() {
        return RetrofitFacade.Companion.getRetrofit().create(CurrentRecordService.class).getRecordActivateRecord();
    }
    /**
     *设备管理-下发记录
     */

    public static Observable<BaseResult<List<Record>>> getRecordOut() {
        return RetrofitFacade.Companion.getRetrofit().create(CurrentRecordService.class).getRecordOutRecord();
    }


    public static void initResult(List<String> timeList,List<Record> recordList){
        String time = recordList.get(0).getTime().split(" ")[0];
        timeList.add(recordList.get(0).getTime());

        for(int i=0;i<recordList.size();i++){
            if(time!=recordList.get(i).getTime().split(" ")[i]){
                timeList.add(recordList.get(i).getTime());
            }
        }

    };
}
